﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MainTemplate.Master" AutoEventWireup="true" CodeBehind="Candidates.aspx.cs" Inherits="Enterprise.Admin.Candidates" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="../Content/Widget/jquery.json.min.js" type="text/javascript" charset="utf-8"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table id="table_list"></table>
    <div id="search_candidates">
        <form id="search_candidates_form">
            <p>
                <label>岗位：</label><input type="text" name="CoPost" />
            </p>
            <p>
                <label>手机：</label><input type="text" name="CoMobile" />
            </p>
            <p>
                <label>电话：</label><input type="text" name="CoPhone" />
            </p>
            <p>
                <label>是否阅读：</label><select name="CoIsRead" class="easyui-combobox" data-options="required:true">
                    <option value="">全部</option>
                    <option value="true">已阅</option>
                    <option value="false">未阅读</option>
                </select>
            </p>
        </form>
    </div>
    <div id="add_candidates">
        <form id="add_candidates_form">
            <div id="add_candidates_tabs" style="padding: 0px; height: auto">
                <div title="应聘基础信息">
                    <p>
                        <label>岗位：</label><input type="text" name="CoPost" />
                    </p>
                    <p>
                        <label>姓名：</label><input type="text" name="CoName" />
                    </p>
                    <p>
                        <label>年龄：</label><input type="text" name="CoAge" />
                    </p>
                    <p>
                        <label>性别：</label>男<input type="radio" name="CoSex" value="男" checked="checked" />女<input type="radio" name="CoSex" value="女" />
                    </p>
                    <p>
                        <label>身份证号：</label><input type="text" name="CoIdentNumber" />
                    </p>
                    <p>
                        <label>学历：</label><input type="text" name="CoEducation" />
                    </p>
                    <p>
                        <label>已阅：</label><input type="checkbox" name="CoIsRead" value="True" />
                    </p>
                    <p>
                        <label>应聘日期：</label><input type="text" name="CoDate" class="easyui-datetimebox" />
                    </p>
                </div>
                <div title="联系方式">
                    <p>
                        <label>手机：</label><input type="text" name="CoMobile" />
                    </p>
                    <p>
                        <label>电话：</label><input type="text" name="CoPhone" />
                    </p>
                    <p>
                        <label>邮箱：</label><input type="text" name="CoEmail" />
                    </p>
                    <p>
                        <label>QQ：</label><input type="text" name="CoQq" />
                    </p>

                </div>
                <div title="个人简介">
                    <textarea rows="10" cols="50" name="CoSummary"></textarea>
                </div>
                <div title="工作经历">
                    <textarea rows="10" cols="50" name="CoWorkHistory"></textarea>
                </div>
            </div>
        </form>
    </div>
    <div id="edit_candidates">
        <form id="edit_candidates_form">

            <div id="edit_candidates_tabs" style="padding: 0px; height: auto">
                <div title="应聘基础信息">
                    <p>
                        <label>岗位：</label><input type="text" name="CoPost" /><input type="hidden" name="CoCandidatesId" />
                    </p>
                    <p>
                        <label>姓名：</label><input type="text" name="CoName" />
                    </p>
                    <p>
                        <label>年龄：</label><input type="text" name="CoAge" />
                    </p>
                    <p>
                        <label>性别：</label>男<input type="radio" name="CoSex" value="男" checked="checked" />女<input type="radio" name="CoSex" value="女" />
                    </p>
                    <p>
                        <label>身份证号：</label><input type="text" name="CoIdentNumber" />
                    </p>
                    <p>
                        <label>学历：</label><input type="text" name="CoEducation" />
                    </p>
                    <p>
                        <label>应聘日期：</label><input type="text" name="CoDate" class="easyui-datetimebox" />
                    </p>
                </div>
                <div title="联系方式">
                    <p>
                        <label>手机：</label><input type="text" name="CoMobile" />
                    </p>
                    <p>
                        <label>电话：</label><input type="text" name="CoPhone" />
                    </p>
                    <p>
                        <label>邮箱：</label><input type="text" name="CoEmail" />
                    </p>
                    <p>
                        <label>QQ：</label><input type="text" name="CoQq" />
                    </p>

                </div>
                <div title="个人简介">
                    <textarea rows="10" cols="50" name="CoSummary"></textarea>
                </div>
                <div title="工作经历">
                    <textarea rows="10" cols="50" name="CoWorkHistory"></textarea>
                </div>
            </div>
        </form>
    </div>

    <script type="text/javascript">
        $(document).ready(function () {
           var tableList = $("#table_list").datagrid({
                title: '应聘信息列表',
                fit: true,
                fitColumns: true,
                autoRowHeight: false,
                url: 'Handle/GetCandidatesListJson.aspx',
                idField: 'id',
                singleSelect: true,
                onClickRow: function (rowIndex, rowData) {
                    $('#table_list').datagrid("unselectRow", rowIndex);
                },
                columns: [[
                         { title: 'Id', field: 'id', width: 280, align: 'center', checkbox: true },
                         { title: '姓名', field: 'CoName', width: 280, align: 'center' },
                         { title: '岗位', field: 'CoPost', width: 100, align: 'center' },
                         { title: '年龄', field: 'CoAge', width: 100, align: 'center' },
                         { title: '性别', field: 'CoSex', width: 100, align: 'center' },
                         { title: '手机', field: 'CoMobile', width: 180, align: 'center' },
                         { title: '电话', field: 'CoPhone', width: 180, align: 'center' },
                         { title: '投历日期', field: 'CoDate', width: 180, align: 'center' },
                     {
                         field: 'CoIsRead', title: '已阅', width: 100, align: 'center',
                         formatter: function (value, rec) {
                             return value ? '是' : '否';
                         }
                     },

                       {
                           title: '修改', field: 'OpEdit', width: 80, align: 'center', formatter: function (value, rec, index) {
                               return '<a href="javascript:void(0);" mce_href="#" onclick="edit(\'' + rec.id + '\')">修改</a> ';
                           }
                       },
                        {
                            title: '删除', field: 'OpDelete', width: 80, align: 'center', formatter: function (value, rec, index) {
                                return '<a href="javascript:void(0);" mce_href="#" onclick="del(\'' + rec.id + '\')">删除</a> ';

                            }
                        }
                ]],
                pagination: true,
                rownumbers: true,
                toolbar: [{
                    text: '添加',
                    iconCls: 'icon-add',
                    handler: function () {
                        add();
                    }
                }, {
                    text: '修改',
                    iconCls: 'icon-edit',
                    handler: function () {
                        var selectData = $('#table_list').datagrid('getSelected');
                        if (selectData == null) {
                            $.messager.show({
                                title: '提示',
                                msg: '请选择要修改记录！',
                                timeout: 5000,
                                showType: 'fade'
                            });
                        } else {
                            edit(selectData.id);
                        }
                    }

                }, {
                    text: '删除',
                    iconCls: 'icon-remove',
                    handler: function () {
                        var selectData = $('#table_list').datagrid('getSelected');
                        if (selectData == null) {
                            $.messager.show({
                                title: '提示',
                                msg: '请选择要删除记录！',
                                timeout: 5000,
                                showType: 'fade'
                            });
                        } else {
                            del(selectData.id);
                        }

                    }

                }, {
                    text: '查找',
                    iconCls: 'icon-search',
                    handler: function () {
                        $('#search_candidates').dialog("open");
                    }

                }]
            });
            $('#add_candidates').dialog({
                title: '添加应聘信息',
                
                width: 750,
                height: 500,
                closed: true,
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: function () {
                        addSave(function () { });
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#add_candidates').dialog('close');
                    }
                }]

            });
            $('#edit_candidates').dialog({
                title: '修改应聘信息',
                
                width: 750,
                height: 500,
                closed: true,
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: function () {

                        editSave();
                    }
                }, {
                    text: '设置已阅',
                    iconCls: 'icon-ok',
                    handler: function () {
                        setIsRead();
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#edit_candidates').dialog('close');
                    }
                }]
            });
            $('#search_candidates').dialog({
                title: '检索应聘信息',
                
                width: 400,
                height: 250,
                closed: true,
                buttons: [{
                    text: '查找',
                    iconCls: 'icon-ok',
                    handler: function () {
                        tableList.datagrid("reload", $('#search_candidates_form').serializeObject());
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#search_candidates').dialog('close');
                    }
                }]
            });
            $('#edit_candidates_form').form({
                onBeforeLoad: function () {
                },
                onLoadSuccess: function (data) {
                    $('#edit_date').datetimebox('setValue', data.CoDate);
                    $('#edit_date').datetimebox('setValue', data.CoDate);
                    $('#edit_candidates').dialog("open");
                },
                onLoadError: function () {

                }
            });

            $('#add_candidates_tabs').tabs({
                border: false
            });
            $('#edit_candidates_tabs').tabs({
                border: false
            });


        });
        //获取招聘信息详细
        function edit(id) {
            $('#edit_candidates_form').form('load', 'Handle/GetCandidatesDetailJson.aspx?id=' + id);
        }
        function del(id) {
            $.messager.confirm("提示", "确认删除?", function (b) {
                if (b) {
                    $.ajax({
                        type: "POST",
                        url: "Handle/DeleteCandidates.aspx",
                        data: { id: id },
                        success: function (msg) {
                            $.messager.show({
                                title: '提示',
                                msg: msg.message,
                                timeout: 5000,
                                showType: 'fade'
                            });
                            if (msg.state)
                                $("#table_list").datagrid("reload");
                        },
                        error: function () {
                            $.messager.show({
                                title: '提示',
                                msg: '删除失败！',
                                timeout: 5000,
                                showType: 'fade'
                            });
                        }
                    });
                }

            });

        }
        function add() {
            $('#add_candidates').dialog("open");
        }
        //添加保存
        function addSave(fn) {
            $.ajax({
                type: "POST",
                url: "Handle/AddCandidates.aspx",
                data: $('#add_candidates_form').serialize(),
                success: function (msg) {
                    $.messager.show({
                        title: '提示',
                        msg: msg.message,
                        timeout: 5000,
                        showType: 'fade'
                    });
                    if (msg.state) {
                        $('#add_candidates_form')[0].reset();
                        $("#table_list").datagrid("reload");
                    }
                },
                error: function () {
                    $.messager.show({
                        title: '提示',
                        msg: '保存失败！',
                        timeout: 5000,
                        showType: 'fade'
                    });
                }
            });
        }
        function setIsRead(fn) {
            $.ajax({
                type: "POST",
                url: "Handle/SetCandidatesIsRead.aspx",
                data: $('#edit_candidates_form').serialize(),
                success: function (msg) {
                    $.messager.show({
                        title: '提示',
                        msg: msg.message,
                        timeout: 5000,
                        showType: 'fade'
                    });
                    if (msg.state) {
                        $('#edit_candidates_form')[0].reset();
                        $("#table_list").datagrid("reload");
                    }
                      
                },
                error: function () {
                    $.messager.show({
                        title: '提示',
                        msg: '设置失败！',
                        timeout: 5000,
                        showType: 'fade'
                    });
                }
            });
        }
        //编辑保存
        function editSave() {
            $.ajax({
                type: "POST",
                url: "Handle/EditCandidates.aspx",
                data: $('#edit_candidates_form').serialize(),
                success: function (msg) {
                    $.messager.show({
                        title: '提示',
                        msg: msg.message,
                        timeout: 5000,
                        showType: 'fade'
                    });
                    if (msg.state)
                        $("#table_list").datagrid("reload");
                },
                error: function () {
                    $.messager.show({
                        title: '提示',
                        msg: '保存失败！',
                        timeout: 5000,
                        showType: 'fade'
                    });
                }
            });
        }
    </script>
</asp:Content>
